package day5;

import java.util.ArrayList;
import java.util.Scanner;

public class DataDemo {
    public static void main(String[] args) {
       ArrayList<Info> list=new ArrayList<>();
        //  ArrayList<Year>list1=new ArrayList<>();
        Info per1=new Info();
        Info per2=new Info();
        Info per3=new Info();
        Year date1=new Year();
        Year date2=new Year();
        Year date3=new Year();

        per1.setName("杨哲");
        per1.setPassId("123456789");
        per1.setBirthday(date1);
        date1.setYear(1999);
        date1.setMonth(5);
        date1.setDay(14);
        per2.setName("唐海元");
        per2.setPassId("10045465865");
        per2.setBirthday(date2);
        date2.setYear(2002);
        date2.setMonth(4);
        date2.setDay(15);
        per3.setName("王宣宣");
        per3.setPassId("1215552413");
        per3.setBirthday(date3);
        date3.setYear(2022);
        date3.setMonth(5);
        date3.setDay(12);
        list.add(per1);
        list.add(per2);
        list.add(per3);
//        list1.add(date1);
//        list1.add(date2);
//        list1.add(date3);
        Scanner sc = new Scanner(System.in);
        insertPersonInfo(list ,sc);
        showPersonInfo(list);
        //date1.runYear(date1.getYear());

    }
    //新增同学的信息
    public static void insertPersonInfo(ArrayList<Info> list ,Scanner scanner){
        //创建人员信息
        Info personInfo=new Info();

        System.out.println("请输入人员的姓名信息");
        personInfo.setName(scanner.next());

        System.out.println("请输入人员的身份证号");
        personInfo.setPassId(scanner.next());

        System.out.println("请输入人员生日信息");
        Year date=new Year();
        date.setYear(scanner.nextInt());
        date.setMonth(scanner.nextInt());
        date.setDay(scanner.nextInt());
        personInfo.setBirthday(date);
        date.runYear(date.getYear());
        System.out.println();
        //将属性放入到集合中
        list.add(personInfo);
        //.list1.add(date);
    }
    //展示所有人员信息
    public static void showPersonInfo(ArrayList<Info> list){

        for (int i = 0; i < list.size(); i++) {
            System.out.println("信息："+list.toString());
            //  for (int j = 0; j < lsit1.size(); j++) {
            //System.out.println("生日:"+lsit1.get(i).getYear()+lsit1.get(i).getMonth()+lsit1.get(i).getDay());
            //  System.out.println("生日："+lsit1.toString());
            //  }
            //System.out.println("姓名:"+list.get(i).getName()+"身份证号"+list.get(i).getPassId());
        }

    }

}
